<template>
  <div class="bid-add">
    <div class="page-title">
      <div>{{bidTableList.pid}} &nbsp;&nbsp;&nbsp;&nbsp;{{bidTableList.pname}}&nbsp;&nbsp;&nbsp;&nbsp;{{ apgeTitle }}</div>
    </div>
    <div class="add-form">
      <!-- 新增项目 -->
      <el-form :model="objectInfoForm.info" label-width="100px" v-if="userInfo === '1' && bidFlag === 'false'">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="部门：">
              <el-select v-model="objectInfoForm.info.department" placeholder="请选择部门" :disabled="userInfo === '1'">
                <el-option
                  v-for="item in department"
                  :key="item.id"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="负责人：">
              <el-input v-model.trim="objectInfoForm.info.principal" placeholder="请输入负责人" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="助理：">
              <el-input v-model.trim="objectInfoForm.info.assistant" placeholder="请输入助理名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目编号：">
              <el-input v-model.trim="objectInfoForm.info.pid"  placeholder="请输入项目编号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="项目名称：">
              <el-input v-model.trim="objectInfoForm.info.pname"  placeholder="请输入项目名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="备案号：">
              <el-input v-model.trim="objectInfoForm.info.recordid" placeholder="请输入备案号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属板块：">
              <el-select v-model.trim="objectInfoForm.info.bk" filterable @change="bkChange" placeholder="请输入所属板块">
                <el-option
                  v-for="item in clientOptions.data"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="委托单位：">
              <el-select v-model.trim="objectInfoForm.info.client" filterable placeholder="请输入委托单位">
                <el-option
                    v-for="item in clientOptions.info"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="招标方式：">
              <el-select v-model="objectInfoForm.info.bidmethod" placeholder="请选择招标方式">
                <el-option
                    v-for="item in bidmethod"
                    :key="item.code"
                    :label="item.label"
                    :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="招标类别：">
              <el-select v-model="objectInfoForm.info.bidcategory" placeholder="请选择招标类别">
                <el-option
                  v-for="item in bidcategory"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="工程类别：">
              <el-select v-model="objectInfoForm.info.enginer" placeholder="请选择工程类别">
                <el-option
                  v-for="item in enginer"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="评标办法：">
              <el-select v-model="objectInfoForm.info.bidway" placeholder="请选择评标办法">
                <el-option
                  v-for="item in bidway"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="公告开始时间：">
              <el-date-picker
                  v-model="objectInfoForm.info.anntimeb"
                  type="date"
                  value-format="YYYY-MM-DD"
                  placeholder="请选择公告开始时间"
                  :size="size"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="公告截止时间：">
              <el-date-picker
                      v-model="objectInfoForm.info.anntimee"
                      type="date"
                      value-format="YYYY-MM-DD"
                      placeholder="请选择公告截止时间"
                      :size="size"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="开标时间：">
              <el-date-picker
                v-model="objectInfoForm.info.opentime"
                value-format="YYYY-MM-DD"
                type="date"
                placeholder="请选择开标时间"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="开标地点：">
              <el-select v-model="objectInfoForm.info.parea" placeholder="请选择开标地点">
                <el-option
                  v-for="item in parea"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="估算价(元)：">
              <el-input v-model.trim="objectInfoForm.info.planprice" placeholder="请输入估算价"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="控制价(元)：">
              <el-input v-model.trim="objectInfoForm.info.controlprice" placeholder="请输入控制价" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否外委：">
              <el-select v-model="objectInfoForm.info.decide" placeholder="请选择是否外委">
                <el-option
                  v-for="item in isSure"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否依法：">
              <el-select v-model="objectInfoForm.info.law" placeholder="请选择是否依法">
                <el-option
                  v-for="item in isSure"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否电子标：">
              <el-select v-model="objectInfoForm.info.online" placeholder="请选择是否是电子标">
                <el-option
                  v-for="item in isSure"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="评标费(元)：">
              <el-input v-model.trim="objectInfoForm.info.pbf" placeholder="请输入评标费"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="评委人数：">
              <el-input v-model.trim="objectInfoForm.info.pbr" placeholder="请输入评委人数"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="备注：">
              <el-input
                      v-model="objectInfoForm.info.remark"
                      :rows="2"
                      type="textarea"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <!-- 结算信息 -->
       <el-form :model="settlementForm.info" label-width="120px" v-if="userInfo === '3' && bidFlag === 'false'">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="项目进度：">
              <el-select v-model="settlementForm.info.progress" placeholder="请选择项目进度">
                <el-option
                  v-for="item in progress2"
                  :key="item.id"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="中标单位名称：">
              <el-input v-model.trim="settlementForm.info.wincompany" placeholder="请输入中标单位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="中标价(元)：">
              <el-input v-model.trim="settlementForm.info.winprice" placeholder="请输入中标价" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="是否内部中标：">
              <el-select v-model="settlementForm.info.inn" placeholder="请选择是否内部中标">
                <el-option
                  v-for="item in isSure"
                  :key="item.code"
                  :label="item.label"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="预定标时间：">
              <el-date-picker
                      v-model="settlementForm.info.stime"
                      value-format="YYYY-MM-DD"
                      type="date"
                      placeholder="请选择预定标时间"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="calibrateFlag === 'true'">
            <el-form-item label="正式定标时间：">
              <el-date-picker
                      v-model="settlementForm.info.ftime"
                      value-format="YYYY-MM-DD"
                      type="date"
                      placeholder="请选择正式定标时间"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注：">
              <el-input
                      v-model="settlementForm.info.remark"
                      :rows="2"
                      type="textarea"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 新增投标信息 -->
      <div class="bid-content" style="margin-bottom: 20px;" v-if="(userInfo === '1' || userInfo === '2' || userInfo === '3') && bidFlag === 'true'">
        <el-button type="primary" @click="addBidItem">加一行</el-button>
        <el-table :data="bidTableList.infoList" border style="width: 100%" max-height="618">
          <el-table-column v-for="(item, index) in tableHeaderList" :key="item.id" align="center" :prop="item.prop" :label="item.label" :width="item.width" :fixed="index === 0 ? true : false" >
            <template #default="scope" v-if="item.prop === 'state'">
              <el-select v-model="bidTableList.infoList[scope.$index][item.prop]" :placeholder="`请选择${item.label}`" :disabled="userInfo !== item.flag && item.flag !== ''">
                <el-option
                        v-for="item in state"
                        :key="item.code"
                        :label="item.label"
                        :value="item.code"
                />
              </el-select>
            </template>
            <template #default="scope" v-else-if="item.prop === 'rtime' || item.prop === 'invocetime' || item.prop === 'wjtime'">
              <el-date-picker
                      :disabled="userInfo !== item.flag && item.flag !== ''"
                      v-model="bidTableList.infoList[scope.$index][item.prop]"
                      value-format="YYYY-MM-DD"
                      type="date"
                      :placeholder="`请选择${item.label}`"
              />
            </template>
            <template #default="scope" v-else-if="item.prop === 'operate'">
              <el-button type="danger" @click="deleteBidItem(scope.$index)" :disabled="userInfo!='1'">删除</el-button>
            </template>
            <template #default="scope" v-else-if="item.prop === 'rprice'">
              <el-input v-model="bidTableList.infoList[scope.$index][item.prop]" :placeholder="`请输入${item.label}`" @blur="rpriceBlur(scope.$index)" :disabled="userInfo !== item.flag && item.flag !== ''" />
            </template>
            <template #default="scope" v-else-if="item.prop === 'winprice'">
              <el-input v-model="bidTableList.infoList[scope.$index][item.prop]" :placeholder="`请输入${item.label}`" @blur="winpriceBlur(scope.$index)" :disabled="userInfo !== item.flag && item.flag !== ''" />
            </template>
            <template #default="scope" v-else>
              <el-input v-model="bidTableList.infoList[scope.$index][item.prop]" :placeholder="`请输入${item.label}`" :disabled="userInfo !== item.flag && item.flag !== ''" />
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="add-button">
      <el-button type="primary" @click="submit">提交</el-button>
      <el-button type="primary" @click="goback">返回</el-button>
    </div>
  </div>
</template>


<script setup>
import { ElMessage } from 'element-plus'
import { department, bidmethod, bidcategory, enginer, bidway, parea, isSure, state, progress,progress2 } from '@/utils/dict.js'
import { userStore } from '@/store/user.js'
import pageApi from '@/api/page.js'
import { clientData } from "@/utils/clientData.js"


// 身份标识
const store = userStore()
const { userInfo,ud } = storeToRefs(store)
const router = useRouter()
const route = useRoute()

// 页面标题
const apgeTitle = ref('')
// 新增项目表单
let objectInfoForm = reactive({
  info: {
    department: ud.value,
    principal: '',
    assistant: '',
    pid: '',
    pname: '',
    recordid: '',
    client: '',
    bidmethod: '',
    bidcategory: '',
    enginer: '',
    bidway: '',
    anntimeb: '',
    anntimee: '',
    opentime: '',
    parea: '',
    planprice: '',
    controlprice: '',
    decide: '',
    law: '',
    online: '',
    pbf: '',
    pbr:'',
    bk: '',
    remark: ''
  }
})
// 投标信息list
let bidTableList = reactive({
  infoList: [],
  pid: '',
  pname: ''
})

const calibrateFlag = route.query.calibrateFlag
const bidFlag = route.query.bidFlag
let  categoryFlag = ''

// 结算信息
let settlementForm = reactive({
  info: {
    progress: '',
    wincompany: '',
    winprice: '',
    winmanager: '',
    behalf: '',
    behalfcard: '',
    winphone: '',
    inn: '',
    stime: '',
    remark: '',
    ftime: ''
  }
})
const tableHeaderList = ref([
  {
    id: 1,
    label: '投标单位名称',
    prop: 'tname',
    width: 170,
    flag: '1'
  },
  {
    id: 2,
    label: '投标金额(元)',
    prop: 'tprice',
    width: 170,
    flag: '1'
  },
  {
    id: 3,
    label: '联系人',
    prop: 'lxr',
    width: 170,
    flag: '1'
  },
  {
    id: 4,
    label: '联系电话',
    prop: 'telephone',
    width: 170,
    flag: '1'
  },
  {
    id: 5,
    label: '投标状态',
    prop: 'state',
    width: 170,
    flag: '1'
  },
  {
    id: 6,
    label: '预定标价(元)',
    prop: 'rprice',
    width: 170,
    flag: '1'
  },
  {
    id: 7,
    label: '中标价(元)',
    prop: 'winprice',
    width: 170,
    flag: '3'
  },
  {
    id: 8,
    label: '中标服务费(元)',
    prop: 'serprice',
    width: 170,
    flag: '3'
  },
  {
    id: 17,
    label: '备注',
    prop: 'remark',
    width: 170,
    flag: ''
  },
  {
    id: 9,
    label: '保证金金额(元)',
    prop: 'cash',
    width: 170,
    flag: '2'
  },
  {
    id: 10,
    label: '退款金额(元)',
    prop: 'rcash',
    width: 170,
    flag: '2'
  },
  {
    id: 11,
    label: '退款时间',
    prop: 'rtime',
    width: 170,
    flag: '2'
  },
  {
    id: 12,
    label: '服务费开票金额(元)',
    prop: 'invoceprice',
    width: 170,
    flag: '2'
  },
  {
    id: 13,
    label: '服务费开票时间',
    prop: 'invocetime',
    width: 170,
    flag: '2'
  },
  {
    id: 14,
    label: '发票号',
    prop: 'invoceid',
    width: 170,
    flag: '2'
  },
  {
    id: 15,
    label: '文件费开票金额(元)',
    prop: 'wjprice',
    width: 170,
    flag: '2'
  },
  {
    id: 16,
    label: '文件费开票时间',
    prop: 'wjtime',
    width: 170,
    flag: '2'
  },
  {
    id: 18,
    label: '操作',
    prop: 'operate',
    width: 150,
    flag: '1'
  }
])

let clientOptions = reactive({
  data: clientData,
  info: []
})


onMounted(() => {
  if ((userInfo.value === '1' || userInfo.value === '2' || userInfo.value === '3') && bidFlag === 'true') {
    apgeTitle.value = '投标信息'
  } else{
    apgeTitle.value = '项目信息'
  }

  if (route.query.id) {
    getObject()
  }
})

// 获取数据详情
const getObject = async () => {
  const id = route.query.id
  const res = await pageApi.getObject({ id })
  if (res.code == '0') {
    if (bidFlag === 'true') {
      // 2、获取投标信息
      bidTableList.infoList = res.data.tenders
      bidTableList.pid=res.data.pid;
      bidTableList.pname=res.data.pname;
      categoryFlag = res.data.bidcategory;
    } else {
      if (userInfo.value === '1') {
        // 1、获取项目信息
        objectInfoForm.info = res.data
      }
      else if(userInfo.value === '3') {
        // 3、获取结算信息
        settlementForm.info = res.data
        if (calibrateFlag!== 'true') {
          settlementForm.info.progress = "预定标";
        } else {
          settlementForm.info.progress = "正式定标";
        }
      }
    }
  } else {
    ElMessage({
      message: res.message,
      type: 'error'
    })
  }
}

const bkChange = (value) => {
  clientOptions.data.forEach(item => {
    if (value === item.value) {
      if (item.children && item.children.length > 0) {
        clientOptions.info = item.children
      } else {
        clientOptions.info = []
      }
    }
  })
}

const addBidItem = () => {
  const obj = {
    tname: '',
    cash: '',
    lxr: '',
    telephone: '',
    state: '未中标',
    rcash: '',
    rtime: '',
    rprice: '',
    serprice: '',
    invocetime: '',
    invoceprice: '',
    invoceid: '',
    wjprice: 500,
    wjtime: '',
    remark: '',
    pid: route.query.id || ''
  }
  bidTableList.infoList.push(obj)
}

const deleteBidItem = (index) => {
  bidTableList.infoList.splice(index, 1)
}
//添加返回
const goback = ()=>{
  router.push({
    path: '/data-center/bid/list'
  })
}

// 预定标价失去焦点
const rpriceBlur = (index) => {
  if (bidTableList.infoList[index].winprice==null && bidTableList.infoList[index].rprice!=null){
    bidTableList.infoList[index].winprice = bidTableList.infoList[index].rprice;
    let result = fwf(categoryFlag,bidTableList.infoList[index].winprice,bidTableList.infoList[index].serprice);
    bidTableList.infoList[index].serprice = result;
  }
}

//中标失去焦点
const winpriceBlur = (index) => {
  let result = fwf(categoryFlag,bidTableList.infoList[index].winprice,bidTableList.infoList[index].serprice);
  bidTableList.infoList[index].serprice = result;
}

//服务费计算公式
const fwf = (categoryFlag,winprice,serprice) => {
  let t1 = 1000000;
  let  t2 = 4000000;
  let t3 = 5000000;
  let t4 = 40000000;
  let t5 = 50000000;
  let t6 = 400000000;
  let t7 = 500000000;
  let t8 = 4000000000;
  let t9 = 5000000000;
  if (categoryFlag == "货物") {
    if (winprice<=1000000) {
      serprice = winprice*0.015;
    }else if (winprice<=5000000) {
      serprice = t1*0.015+ (winprice-t1)*0.011;
    }else if (winprice<=10000000) {
      serprice = t1*0.015 + t2*0.011+ (winprice-t1-t2)*0.008;
    }else if (winprice<=50000000) {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + (winprice-t1-t2-t3)*0.005;
    }else if (winprice<=100000000) {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + t4*0.005+ (winprice-t1-t2-t3-t4)*0.0025;
    }else if (winprice<=500000000) {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + t4*0.005+ t5*0.0025 + (winprice-t1-t2-t3-t4-t5)*0.0005;
    }else if (winprice<=1000000000) {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + t4*0.005+ t5*0.0025 + t6*0.0005+ (winprice-t1-t2-t3-t4-t5-t6)*0.00035;
    }else if (winprice<=5000000000) {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + t4*0.005+ t5*0.0025 + t6*0.0005+ t7*0.00035 + (winprice-t1-t2-t3-t4-t5-t6-t7)*0.00008;
    }else if (winprice<= 10000000000) {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + t4*0.005+ t5*0.0025 + t6*0.0005+ t7*0.00035 + t8*0.00008+ (winprice-t1-t2-t3-t4-t5-t6-t7-t8)*0.00006;
    } else {
      serprice = t1*0.015 + t2*0.011+ t3*0.008 + t4*0.005+ t5*0.0025 + t6*0.0005+ t7*0.00035 + t8*0.00008+ t9*0.00006 + (winprice-t1-t2-t3-t4-t5-t6-t7-t8-t9)*0.00004;
    }
  }
  if (categoryFlag == "服务") {
    if (winprice<=1000000) {
      serprice = winprice*0.015;
    }else if (winprice<=5000000) {
      serprice = t1*0.015+ (winprice-t1)*0.008;
    }else if (winprice<=10000000) {
      serprice = t1*0.015+ t2*0.008+ (winprice-t1-t2)*0.0045;
    }else if (winprice<=50000000) {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ (winprice-t1-t2-t3)*0.0025;
    }else if (winprice<=100000000) {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ t4**0.0025+ (winprice-t1-t2-t3-t4)*0.001;
    }else if (winprice<=500000000) {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ t4**0.0025+ t5*0.001+ (winprice-t1-t2-t3-t4-t5)*0.0005;
    }else if (winprice<=1000000000) {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ t4**0.0025+ t5*0.001+ t6*0.0005+ (winprice-t1-t2-t3-t4-t5-t6)*0.00035;
    }else if (winprice<=5000000000) {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ t4**0.0025+ t5*0.001+ t6*0.0005+ t7*0.00035 + (winprice-t1-t2-t3-t4-t5-t6-t7)*0.00008;
    }else if (winprice<= 10000000000) {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ t4**0.0025+ t5*0.001+ t6*0.0005+ t7*0.00035 + t8*0.00008+  (winprice-t1-t2-t3-t4-t5-t6-t7-t8)*0.00006;
    } else {
      serprice = t1*0.015+ t2*0.008+ t3*0.0045+ t4**0.0025+ t5*0.001+ t6*0.0005+ t7*0.00035 + t8*0.00008+ t9*0.00006+ (winprice-t1-t2-t3-t4-t5-t6-t7-t8-t9)*0.00004;
    }
  }
  if (categoryFlag == "工程") {
    if (winprice<=1000000) {
      serprice = winprice*0.010;
    }else if (winprice<=5000000) {
      serprice = t1*0.010 + (winprice-t1)*0.007;
    }else if (winprice<=10000000) {
      serprice = t1*0.010 + t2*0.007+ (winprice-t1-t2)*0.0055;
    }else if (winprice<=50000000) {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ (winprice-t1-t2-t3)*0.0035;
    }else if (winprice<=100000000) {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ t4*0.0035+ (winprice-t1-t2-t3-t4)*0.002;
    }else if (winprice<=500000000) {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ t4*0.0035+ t5*0.002 + (winprice-t1-t2-t3-t4-t5)*0.0005;
    }else if (winprice<=1000000000) {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ t4*0.0035+ t5*0.002 +t6*0.0005+ (winprice-t1-t2-t3-t4-t5-t6)*0.00035;
    }else if (winprice<=5000000000) {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ t4*0.0035+ t5*0.002 +t6*0.0005+ t7*0.00035 + (winprice-t1-t2-t3-t4-t5-t6-t7)*0.00008;
    }else if (winprice<= 10000000000) {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ t4*0.0035+ t5*0.002 +t6*0.0005+ t7*0.00035 + t8*0.00008 + (winprice-t1-t2-t3-t4-t5-t6-t7-t8)*0.00006;
    } else {
      serprice = t1*0.010 + t2*0.007 + t3*0.0055+ t4*0.0035+ t5*0.002 +t6*0.0005+ t7*0.00035 + t8*0.00008 + t9**0.00006 + (winprice-t1-t2-t3-t4-t5-t6-t7-t8-t9)*0.00004;
    }
  }
  return serprice;
};


const submit = async () => {
  let url = ''
  let params = null
  let progress = null
  if (userInfo.value === '1') {
    progress = "已开标"
  }else if (userInfo.value === '2') {
    progress = "已确认"
  }
  if (bidFlag === 'true') {
    // 投标信息
    url = 'tender/add';
    params = {tenders:[...bidTableList.infoList],progress:progress}
  } else {
    if (userInfo.value === '1') {
      if (route.query.id) {
        url = '/project/modify'
      } else {
        url = 'project/add'
      }
      params = { ...objectInfoForm.info }
    } else if(userInfo.value === '3') {
      url = 'project/settle'
      params = {...settlementForm.info}
    }
  }
  const res = await pageApi.submit(url, params)
  if (res.code == '0') {
    ElMessage({
      message: `${apgeTitle.value}提交成功`,
      type: 'success'
    })
    router.push({
      path: '/data-center/bid/list'
    })
  } else {
    ElMessage({
      message: res.message,
      type: 'error'
    })
  }
}
</script>


<style scoped lang="scss">
:deep(.el-form) {
  .el-form-item {
    margin-bottom: 0.3rem;
    .el-select, .el-date-editor {
      width: 100%;
    }
    .el-form-item__label {
      padding: 0;
      color: #333;
      font-size: 0.16rem;
    }
    .el-input__inner {
      color: #333333;
      height: 0.36rem;
      line-height: 0.36rem;
      font-size: 0.16rem;
    }
  }
}
:deep(.el-date-editor) {
  width: 100% !important;
}
.el-button {
  width: 1rem;
  height: 0.4rem;
  font-size: 0.16rem;
}
.el-button--danger {
  width: 0.6rem;
  height: 0.3rem;
}
:deep(.el-table) {
  margin-top: 0.16rem;
  .el-table__header {
    font-size: 0.16rem;
    thead {
      color: #333333;
    }
  }
  .el-table__cell {
    padding: 0.12rem 0;
  }
}
</style>